Skip to content

PDF thumbnail example: keep the thumbnail inside 300x300 - #123

Merged
tomasr78 merged 2 commits into
mainfrom
fix-pdf-thumbnail-example
Nov 9, 2026
Merged

tomasr78 merged 2 commits into
mainfrom
fix-pdf-thumbnail-example

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The example has made the thumbnail in one pdf -> jpg call since fd2449c. It asks for ImageHeight 300 and ImageWidth 300, but returns 300x388 for the portrait test.pdf: without FitToSize the API applies the width, keeps the aspect ratio and lets the height grow.

Change

FitToSize: true fits the image inside both limits: 231x300. The PHP, Python, Ruby, Java and .NET thumbnail examples now produce the same file.

Verification

Run from the repository root after npm ci && npm run build, Node v24.20.0, production API, 2026-11-06. $TMPDIR is the local temp folder:

$ node examples/create_pdf_thumbnail.js        # main d638dae
The thumbnail saved to
$TMPDIR/test.jpg

test.jpg: 300x388 px, 13,317 bytes.

$ node examples/create_pdf_thumbnail.js        # this branch
The thumbnail saved to
$TMPDIR/test.jpg

test.jpg: 231x300 px, 8,858 bytes.

CI runs the examples against staging, whose pdf -> jpg also has FitToSize (spec).

Only the example changes, not the library, so there is no CHANGELOG entry.

The thumbnail examples of the other SDKs are fixed in ConvertAPI/convertapi-library-python#61, ConvertAPI/convertapi-library-php#72, ConvertAPI/convertapi-library-ruby#42, ConvertAPI/convertapi-library-java#56, ConvertAPI/convertapi-library-dotnet#82.

🤖 Generated with Claude Code

Without FitToSize, the ImageHeight=300 / ImageWidth=300 request came back
300x388 for the portrait test.pdf: the width was applied, the height was
not. FitToSize fits the image inside both limits (231x300).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the example-only change that enables proportional thumbnail fitting within 300×300 pixels.

No open issues 🎉

What changed in this PR

Updates the PDF thumbnail example to fit the output within 300×300 pixels while preserving its aspect ratio. Library behavior is unchanged.

Changes:

  • Adds FitToSize: true alongside the existing width and height limits.
File Description
examples/​create_pdf_thumbnail.js Enables proportional fitting within both thumbnail size limits.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 9, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the example-only thumbnail sizing change.

No open issues 🎉

Review effort: Balanced

@tomasr78
tomasr78 merged commit 42b50b3 into main Nov 9, 2026
5 checks passed
@tomasr78
tomasr78 deleted the fix-pdf-thumbnail-example branch November 9, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants